<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
    <b>标题</b><input id="title" type="text"/>
    <b>作者</b><input id="author" type="text"/>
    <b>图片链接</b><input id="imageUrl" type="text">
    <div id="editor">
        <p>欢迎使用 <b>treasure</b> 富文本编辑器</p>
    </div>
    <button id="btn">获取html</button>

    <!-- 引入 js -->
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/wangEditor/10.0.13/wangEditor.min.js"></script>
    <script>
        let E = window.wangEditor; // 全局变量
        let editor = new E('#editor');
        editor.create()
        document.getElementById('btn').addEventListener('click', function (e) {
            console.log(editor.txt.html())
            // let data = {
            //     "title": document.getElementById("title").value,
            //     "author": document.getElementById("author").value,
            //     "content": editor.txt.html(),
            //     "imageUrl": document.getElementById("imageUrl").value
            // }
            //
            // $.ajax({
            //     url: "http://localhost:8080/treasure/upload",
            //     type: "POST",
            //     contentType: "application/json",
            //     dataType: "json",
            //     data: JSON.stringify(data),
            //     success:function (res){
            //         console.log(res)
            //     },
            //     error:function (e){
            //         console.log(e)
            //     }
            // })
        }, false);


    </script>
</body>
</html>